﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "考场签到单");
		
		examId = event.getArg("EXID");

		/* 学校信息 */
	
		/* 加载考试任务 */
	
		sql = "SELECT a.task_exrstid,
					   b.course_name,
					   b.course_code,
					   b.course_credit,
					   c.institute_name,
					   d.academic_year,
					   d.academic_term 
				FROM t_resittask a 
					 INNER JOIN t_course b ON b.cid = a.cid 
					 INNER JOIN t_institute c ON c.institute_id = b.institute_id 
					 INNER JOIN t_term d ON d.term_id = a.term_id 
				WHERE a.task_exrstid = :examId ";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		
		rs_examTask= queryObj.execute( sql=sql ).getResult();
		
		/* 考场列表 */
							
		sql = "SELECT 
				a.cr_id
				FROM t_clsroom_timetable a 
					 INNER JOIN t_clsroom_forresit b ON b.crtime_id = a.crtime_id 
					 INNER JOIN t_classroom d ON d.cr_id = a.cr_id
					 INNER JOIN t_campus c ON c.campus_id = d.campus_id 
					 INNER JOIN t_building e ON e.b_id = d.b_id 
				WHERE 
					b.task_exrstid = :examId 
				ORDER BY  
					c.campus_name, 
					e.b_name,
					d.cr_floor, 
					d.classroom ";
				
		queryObj = new Query( datasource=application.dnsSlave ) ;
   		queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" );
		
		rs_room= queryObj.execute( sql=sql ).getResult();
		
		
		/* 默认显示行数及高度 */
		rowPerSlide = 40;
		rowPerPage = rowPerSlide * 2;
		
	</cfscript>
</cfsilent>

<cfloop query="rs_room" >

    <cfset clsroomId = rs_room.cr_id  />
    
    <cfset sql = "SELECT a.classroom 
					FROM t_classroom a 
					WHERE a.cr_id = :clsroomId " />
                    
    <cfset queryObj = new Query( datasource=application.dnsSlave )/>
    <cfset queryObj.addParam( name="clsroomId", value=clsroomId, cfsqltype="cf_sql_char" )/>
    
    <cfset rs_classRoom= queryObj.execute( sql=sql ).getResult()/>
	
	<!---  /* 考场名单 */ --->
	                              
    <cfset sql = "SELECT 
					a.sitidx, 
					b.stu_id, b.stu_name,
          			b.stu_sex 
					FROM t_student_resit a  
						INNER JOIN t_student b ON b.stu_id = a.stu_id 
					WHERE 
						a.task_exrstid = :examId 
						AND 
						a.cr_id = :clsroomId 
					ORDER BY a.sitidx" />
                    
    <cfset queryObj = new Query( datasource=application.dnsSlave )/>
    <cfset queryObj.addParam( name="examId", value=examId, cfsqltype="cf_sql_char" )/>
    <cfset queryObj.addParam( name="clsroomId", value=clsroomId, cfsqltype="cf_sql_char" )/>
    <cfset rs_student= queryObj.execute( sql=sql ).getResult()/>
    
	<cfif rs_student.recordCount>
		
		<!--- /* 计算打印页数 */ --->
		<cfif rs_student.recordCount mod rowPerPage>
			<cfset totlePageCount = int(rs_student.recordCount/rowPerPage) + 1 />
			<cfelse>
			<cfset totlePageCount = int(rs_student.recordCount/rowPerPage) />
		</cfif>
		
		<cfset pageRowBegin = 1 />
		<cfset pageRowEnd = min(rowPerPage, rs_student.recordCount) />
		<cfset tagCode = "QDB-" & rs_examTask.task_exrstid />
		
	</cfif>
	
	<!--- 考场间分页 --->
	<cfif clsroomId neq rs_room["cr_id"][1]><div class="page_break"></div></cfif>

	<cfloop from="1" to="#totlePageCount#" index="currentPage">
	
		<cfif currentPage GT 1><div class="page_break"></div></cfif>
		
		<div class="UIreportTitle">
			<h2><cfoutput>#rs_examTask.course_name#</cfoutput> 补考 <cfoutput>#rs_classRoom.classroom#</cfoutput> 考场签到表</h2>
		</div>
		
		<table width="98%" border="0" cellpadding="1" cellspacing="0">
			<tr>
				<td>课程号 <cfoutput>#rs_examTask.course_code#</cfoutput></td>
				<td>课程 <cfoutput>#rs_examTask.course_name#</cfoutput></td>
				<td>学分 <cfoutput>#numberFormat(rs_examTask.course_credit, "_.__")#</cfoutput></td>
				<td align="right">任课单位 <cfoutput>#rs_examTask.institute_name#</cfoutput></td>
			</tr>
			<tr>
				<td>学期 <cfoutput>#rs_examTask.academic_year#</cfoutput>-<cfoutput>#rs_examTask.academic_term#</cfoutput></td>
				<td>考场 <cfoutput>#rs_classRoom.classroom#</cfoutput></td>
				<td>考场人数 <cfoutput>#rs_student.recordCount#</cfoutput></td>
				<td align="right">第<cfoutput>#currentPage#</cfoutput>页 共<cfoutput>#totlePageCount#</cfoutput>页</td>
			</tr>
		</table>
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td valign="top" width="50%"><!-- Silder Left -->
					
					<table class="UIprintable" width="100%" border="1" cellpadding="0" cellspacing="0">
						<tr>
							<td width="30">序</td>
							<td width="100">学号</td>
							<td width="80">姓名</td>
							<td width="30">性别</td>
							<td>签字</td>
						</tr>
						<cfset sliderRowBegin = pageRowBegin />
						<cfset sliderRowEnd = pageRowBegin + rowPerSlide -1 />
						<cfloop index="row" from="#sliderRowBegin#" to="#sliderRowEnd#">
							<cfif rs_student.recordCount gte row >
								<tr>
									<td><cfoutput>#rs_student["sitidx"][row]#</cfoutput></td>
									<td><cfoutput>#rs_student["stu_id"][row]#</cfoutput></td>
									<td align="left"><cfoutput>#rs_student["stu_name"][row]#</cfoutput></td>
									<td><cfif rs_student["stu_sex"][row] eq "1">
											男
											<cfelse>
											女
										</cfif></td>
									<td>&nbsp;</td>
								</tr>
								<cfelse>
								<tr>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
								</tr>
							</cfif>
						</cfloop>
					</table></td>
				<td width="5" valign="top">&nbsp;</td>
				<td valign="top" width="50%"><!-- Silder Right -->
					
					<table class="UIprintable" width="100%" border="1" cellpadding="0" cellspacing="0">
						<tr>
							<td width="30">序</td>
							<td width="100">学号</td>
							<td width="80">姓名</td>
							<td width="30">性别</td>
							<td>签字</td>
						</tr>
						<cfset sliderRowBegin = pageRowBegin + rowPerSlide />
						<cfset sliderRowEnd = pageRowBegin + 2*rowPerSlide -1 />
						<cfloop index="row" from="#sliderRowBegin#" to="#sliderRowEnd#">
							<cfif rs_student.recordCount gte row >
								<tr>
									<td><cfoutput>#rs_student["sitidx"][row]#</cfoutput></td>
									<td><cfoutput>#rs_student["stu_id"][row]#</cfoutput></td>
									<td align="left"><cfoutput>#rs_student["stu_name"][row]#</cfoutput></td>
									<td><cfif rs_student["stu_sex"][row] eq "1">
											男
											<cfelse>
											女
										</cfif></td>
									<td>&nbsp;</td>
								</tr>
								<cfelse>
								<tr>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
									<td>&nbsp;</td>
								</tr>
							</cfif>
						</cfloop>
					</table></td>
			</tr>
		</table>
		<div class="clear2px"></div>
		<table width="100%" cellpadding="0" cellspacing="0">
			<tr>
				<td width="150">打印时间 <cfoutput>#dateFormat(now(), "YYYY年MM月DD日")#</cfoutput></td>
				<td width="180">监考教师签名</td>
				<td width="100">第 <cfoutput>#currentPage#</cfoutput> 页, 共 <cfoutput>#totlePageCount#</cfoutput> 页</td>
				<td align="right"><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/Print/<cfoutput>#tagCode#</cfoutput>,<cfoutput>#currentPage#</cfoutput>.png" height="43"/></td>
			</tr>
		</table>
		<cfset pageRowBegin = pageRowBegin + rowPerPage />
		<cfset pageRowEnd = pageRowEnd + rowPerPage />
		<cfif pageRowEnd gt rs_student.recordCount>
			<cfset pageRowEnd = rs_student.recordCount />
		</cfif>
	</cfloop>
</cfloop>
